

<template>
    <div>
   <h1>新增页面</h1>
    </div>
     <table class="table">
        <thead>
                 <tr>
                <td>编号</td>
                   <td>
                    <input type="text" v-model="data.code" disabled>
                   </td>
            </tr>

            <tr>
                <td>姓名</td>
                   <td>
                    <input type="text" v-model="data.employeeName" disabled>
                   </td>
            </tr>

             <tr>
                <td>密码</td>
                   <td>
                      <input type="password" v-model="data.employeePwd">
                   </td>
            </tr>

             <tr>
                <td>年龄</td>
                   <td>
                 <input type="text" v-model="data.num">
                   </td>
            </tr>

             <tr>
                <td>出生日期</td>
                <td>
                     <input type="date" v-model="data.employeeDate">
                </td>
            </tr>

             <tr>
                <td>图片</td>
                   <td>
                    <input type="file" @change="sr">
                    <img style="width:45px;height:45px;" :src="axios.defaults.baseURL+data.employeeImg">
                   </td>
            </tr>

             <tr>
                <td>性别</td>
                   <td>
                    <input type="radio"  name="sex" value="1" v-model="data.sex"/>男
                        <input type="radio" name="sex" value="2" v-model="data.sex"/>女
                   </td>
            </tr>

                 <tr>
                <td>状态</td>
                   <td>
                    <select v-model="data.statusId">
                        <option value="0">==请选择==状态</option>
                        <option v-for="a in obj" :value="a.statusId">{{a.statusName}}</option>
                    </select>
                   </td>
            </tr>

             <tr>
                <td>入职成功</td>
                   <td>
                    <input type="radio" name="isDeleted" value="true" v-model="data.isDeleted" disabled>成功
                   <input type="radio"  name="isDeleted" value="false" v-model="data.isDeleted" disabled>未成功
                   </td>
            </tr>

                <tr>
                <td></td>
                   <td>
                    <input type="button" value="修改" @click="updates()">
                   </td>
            </tr>
        </thead>
     </table>
</template>

<script setup lang="ts">
  import axios from 'axios';
import { updateLanguageServiceSourceFile } from 'typescript';
   import {ref,onMounted} from  'vue';
  import {useRouter,useRoute} from 'vue-router';
  import moment from 'moment';
import type { RefSymbol } from '@vue/reactivity';
    const router=useRouter();
  const route=useRoute();
   onMounted(()=>{
    FindEmployee();
    statuses();
   })

  const sr=(ad:any)=>{
   
     let f=ad.target.files[0];
      let fs=new FormData();
       fs.append("file",f);
        axios.post("/api/uPLOAD/Uploa",fs).then(res=>{
               data.value.employeeImg=res.data;
       
        })
  }

  

  const FindEmployee=()=>{
     
       let employeeId=route.query.ids
     axios.get("https://localhost:7164/api/Employee/FindEmployee?id="+employeeId).then(res=>{


      
      data.value=res.data;
      data.value.employeeDate=moment(data.value.employeeDate).format("YYYY-MM-DD")
     })
  }

   const data=ref({

  "isDelete": true,
  "createUserId": 0,
  "createDate": "2025-06-08T11:26:24.552Z",
  "updateUserId": 0,
  "updateDate": "2025-06-08T11:26:24.552Z",
  "deleteUserId": 0,
  "deleteDate": "2025-06-08T11:26:24.552Z",
  "employeeId": 0,
  "code": "",
  "employeeName": "",
  "employeePwd": "",
  "num": 0,
  "employeeDate": "2025-06-08T11:26:24.553Z",
  "employeeImg": "string",
  "sex": 0,
  "statusId": 0,
  "isDeleted": true

   })

    
     const updates=()=>{
        axios.post("https://localhost:7164/api/Employee/UpdateAnync",data.value).then(res=>{
  
     
             if(res.data>0){

              alert("修改成功")

                router.push("/sho")

             }else{
                        alert("修改成功")
             }
        })
     }



    const obj=ref([{
    "statusId": 0,
    "statusName": "",
    "isDelete": false,
    "createUserId": 0,
    "createDate": "0001-01-01T00:00:00",
    "updateUserId": 0,
    "updateDate": null,
    "deleteUserId": 0,
    "deleteDate": null
    }])

    const statuses=()=>{
         axios.get("/api/StatusBll/statuses").then(res=>{
  obj.value=res.data;

         })
    }

    
</script>

<style scoped>

</style>    